package bdz.framework.web.vo
{
	import flash.events.EventDispatcher;

	public class BDZWFTemplate extends EventDispatcher
	{
		
		private var _source:XML;
		private var _templateuis:Array;
		public function BDZWFTemplate(xm:XML = null)
		{
			super();
			initializeComponent(xm);
		}
		private function initializeComponent(xm:XML):void{
			_templateuis = new Array();
			if(xm == null){
				_source = new XML("<df_templates/>");
				return;
			}
			_source = xm;
			var tuis:XMLList = xm.template_uis.ui;
			for each(var tui:XML in tuis){
				_templateuis.push(new BDZWFTemplateUI(tui));	
			}
			
		}
		public function addUI(tui:BDZWFTemplateUI):void{
			_templateuis.push(tui);
		}
		public function get template_name():String{
			return _source.template_name.toString();
		}
		public function set template_name(str:String):void{
			_source.template_name = str;
		}
		public function get parent_id():Number{
			return Number(_source.parent_id.toString());
		}
		public function set parent_id(n:Number):void{
			_source.parent_id = n;
		}
		public function get template_id():Number{
			return Number(_source.template_id.toString());
		}
		public function get content_type():String{
			return _source.content_type.toString();
		}
		public function set content_type(str:String):void{
			_source.content_type = str;
		}
		public function get control_type():String{
			return _source.control_type.toString();
		}
		public function set control_type(str:String):void{
			_source.control_type = str;
		}
		public function get client_component():String{
			return _source.client_component.toString();
		}
		public function set client_component(str:String):void{
			_source.client_component = str;
		}
		public function get source():XML{
			_source.template_uis = new XML("<template_uis/>");
			var uis:XMLList = new XMLList();
			var counter:Number = 0;
			for each(var tdata:BDZWFTemplateUI in _templateuis){
				uis[counter] = tdata.source;
				counter++;
			}
			_source.template_uis.ui = uis;
			return _source;
		}
		
		public function get uis():Array{
			return _templateuis;
		}
	}
}